home *** CD-ROM | disk | FTP | other *** search
/ APDL Eductation Resources / APDL Eductation Resources.iso / programs / database / powerbase / docs / Utils < prev    next >
Encoding:
Text File  |  1997-02-21  |  8.7 KB  |  152 lines

  1.                            CH 10 − UTILITIES
  2.                            =================
  3. All the procedures described in this chapter are initiated by choices from
  4. the Utilities submenu of the icon-bar menu to examine and alter the
  5. structure of an existing database. Note that, if passwords have been set,
  6. you need to enter the database with the “Manager”-level password to obtain
  7. access to this submenu.
  8.  
  9. 10.1  Changing the Primary Key
  10. ==============================
  11. The primary key of a database is determined when it is created, but is not
  12. fixed for all time. The New primary key choice displays the same dialogue
  13. box as used for creating the primary key in the first place, but with the
  14. addition of two radio buttons, whose function is described below. The
  15. present key structure is shown. Simply alter it to what you require and
  16. click on Create or type Return.
  17.  
  18. Normally the first of the two radio buttons (Retain subfile structure) is
  19. selected, making the records appear in the same subfiles as before. In this
  20. case, any additional indices will still be valid. If you deselect this radio
  21. button with ADJUST (i.e. have neither button selected) then all the records
  22. will be placed in the currently selected subfile.
  23.  
  24. Selecting the second button (Ignore old primary key) also places the records
  25. in the current subfile, but has the additional effect of recovering
  26. “deleted” records, i.e. records which are still lurking in the Database file
  27. but aren’t in the primary key index. One important circumstance under which
  28. you would need to use this option is  when the primary key index is lost or
  29. corrupted.
  30.  
  31. NOTE: You might have a Database file but no PrimaryKey file at all. This
  32. could happen if you have, for example, created a suitable text file and then
  33. set its type to Database.  To build a primary key for such a file the only
  34. valid setting for the radio buttons is the one just described, i.e. second
  35. button selected.  To enforce this mode both radio buttons are shaded.
  36.  
  37. 10.2  Adjusting the record format
  38. =================================
  39. Minor changes to the screen layout can be made without having to rebuild the
  40. database. Choose Adjust format and you will be presented with the blank
  41. record screen. Clicking MENU over this  brings up the same menu as you used
  42. to create the screen originally, but the Field definition window has some
  43. options shaded. Thus you can’t delete fields, add new ones or alter the data
  44. lengths, but you can re-position fields, change descriptors and tags, and
  45. alter the visible lengths. When you have finished the changes, choose the
  46. last option on the menu; Quit design.
  47.  
  48. 10.3  Changing the record format
  49. ================================
  50. This is more drastic, but it is not always possible to foresee future needs
  51. and you may have to introduce a new field or lengthen an existing one. To do
  52. so you must rebuild the whole database. You will need to create a new
  53. application shell with the new Form file inside it. The best way to do this
  54. is to open the new database directory, copy the old Form file into it, then
  55. double-click on the new “database”. As no PrimaryKey or Database file exists
  56. yet you will be able to modify the screen design as you wish. You should
  57. not, however, go on to complete the empty database (i.e. don’t choose
  58. Default database or click on the Create button in the Key structure window)
  59. − simply save the Form file using the menu choice provided.
  60.  
  61. With the old database open, choose New record format. Drag the new database
  62. to the large arrow icon in the displayed window and click on Reformat. The
  63. database will then be rebuilt. Make sure you have plenty of disc space
  64. available before doing this as the original remains intact so you need room
  65. for both it and the new one. Data from a field in the old database is copied
  66. to a field in the new one with the same tag. The new Form file must
  67. therefore retain the same tags as the old for data which is to be common to
  68. both. If a tag exists in the old Form file but not in the new one Powerbase
  69. will assume that the relevant field has been deleted and data present in
  70. that field in the old database will not be transferred. A tag which is
  71. present in the new database but not in the old is assumed to be a
  72. newly-introduced field and will therefore be left blank.
  73.  
  74. When the process is complete you will find that the new database contains
  75. all your old data but in the new record format. Links to validation tables
  76. are preserved but formulae for self-calculating fields will need to be
  77. re-initialised by opening the formula window for each and clicking OK (see
  78. 6.1.1).
  79.  
  80. 10.4  Merging two databases
  81. ===========================
  82. Two databases may be merged provided they have the same record structure.
  83. With the first database open, select Merge database and drag the second
  84. database to the arrow icon in the displayed window. Powerbase will check
  85. that the two record formats are identical and report an error if they
  86. aren’t. If the open database has insufficient free space to hold the merged
  87. records it is automatically extended.  An option switch determines the
  88. action taken with regard to Sequence number fields (see 8.4.1).
  89.  
  90. Two radio buttons are also present, as in the dialogue box for rebuilding
  91. the primary key, and their functions are essentially the same. Having the
  92. first button selected merges records into the same subfiles as those they
  93. occupied in the source database. Having neither selected merges records into
  94. the current subfile of the open database, regardless of where they are in
  95. the source database. Having the second button selected does the same, but
  96. also imports records which were “deleted” in the source database.
  97.  
  98. 10.5  Changing the Database Length
  99. ==================================
  100. Lengthening a database is often required, shortening is less common, but
  101. both are easily accomplished. Change length leads to a window with two
  102. writable icons. The first specifies the new database length. You will be
  103. warned if, when shortening a database, any records being removed are not
  104. blank. The data they contain might belong to deleted records, but might not.
  105. You have been warned! The other writable icon determines the number of
  106. records by which the database will be lengthened each time it becomes full.
  107. If this value is zero no automatic lengthening occurs; a warning is
  108. displayed instead.
  109.  
  110. 10.6  Inspecting and balancing index trees
  111. ==========================================
  112. Print index lets you examine the structure of the current index to find out
  113. how many keys are present in each level. The ideal numbers in a
  114. perfectly-balanced index tree are 1, 2, 4, 8, 16, 32, 64, 128 etc. (i.e.
  115. powers of 2, beginning with 20.) A submenu gives you the option of printing
  116. the actual keys, positioned according to the level they occupy in the tree,
  117. or printing only the total number of nodes in each level.
  118.  
  119. The data printed applies to the current subfile of the current key and is
  120. output to a screen window from which it may be saved in the same way as any
  121. other list. (If you have printed the keys themselves then double-clicking
  122. with SELECT on any key will call up the associated database record.)
  123.  
  124. If the tree is very deep and straggly it may not be possible to show all of
  125. it. The maximum number of levels which can be shown is in fact 40, including
  126. the root. Using option (1) above causes keys which cannot be displayed in
  127. their correct positions to appear down the left hand side of the window with
  128. a note indicating the level in which they occur.
  129.  
  130. If the tree is very unbalanced, i.e. if it departs dramatically from the
  131. “powers-of-two” pattern described above and, especially, if there is an
  132. enormous number of levels with only 1 or 2 keys in each, you are advised to
  133. balance it using the Balance index choice*. It is also possible to make
  134. Powerbase balance the index automatically at regular intervals.  To turn on
  135. auto-balancing choose Preferences  from the icon-bar menu.  Select the
  136. Balance every <n> records switch, placing your chosen value of n in the
  137. writable icon provided, then click on Accept.
  138.  
  139. Auto-balancing is most likely to be used when a large number of records are
  140. being entered in primary-key-order.  This will happen if you are entering
  141. data from a lot of forms in alphabetical order of name where name is the
  142. primary key.  It is also very likely to happen when importing CSV files as
  143. these are often ordered according to the data item which becomes the primary
  144. key field of the database record.
  145.  
  146. 10.7  Finding duplicate primary keys
  147. ====================================
  148. Wherever possible a primary key should be chosen so as to be unique. Where
  149. duplication of the primary key might occur the designer of the database can
  150. decide either to allow or forbid it (see 11.2.1). If duplicate keys are
  151. permitted it is sometimes useful to have a list of them. Such a list is
  152. created by Find duplicates and may be saved as a text file.